package com.flyme.module.base.provider.service.impl;
import com.flyme.common.core.model.query.CriteriaQuery;
import com.flyme.core.base.supper.entity.EntityMap;
import com.flyme.core.base.supper.service.impl.BaseServiceImpl;
import com.flyme.module.base.client.entity.SysExatime;
import com.flyme.module.base.provider.mapper.SysExatimeMapper;
import com.flyme.module.base.provider.service.SysExatimeService;
import com.flyme.module.order.client.enums.OrderStatusEnum;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SysExatimeServiceImpl extends BaseServiceImpl<SysExatimeMapper, SysExatime> implements SysExatimeService {

    @Override
    public EntityMap getIndexBegin(Long examinationId){
        CriteriaQuery cq = new CriteriaQuery<SysExatime>();
        cq.select(" CONCAT(e.examTime,' ',e.examStartTime) beginTime");
        cq.eq("examseason.examinationId", examinationId);
        cq.orderByAsc("e.examTime");
        cq.orderByAsc("e.examStartTime");
        cq.last("LIMIT 1");
        cq.createAlias("examseason", "examseason");
        return getEntityMap(cq);
    }

    @Override
    public EntityMap getIndexEnd(Long examinationId){
        CriteriaQuery cq = new CriteriaQuery<SysExatime>();
        cq.select(" CONCAT(e.examTime,' ',e.examendTime) endTime");
        cq.eq("examseason.examinationId", examinationId);
        cq.orderByDesc("e.examTime");
        cq.orderByDesc("e.examendTime");
        cq.last("LIMIT 1");
        cq.createAlias("examseason", "examseason");
        return getEntityMap(cq);
    }


}
